package com.project.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.project.bean.CarBean;
import com.project.mapper.ICarMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class CarServiceImpl implements ICarService{
    @Autowired
    private ICarMapper carMapper;
    @Override
    public PageInfo<CarBean> findByItem(int pageNO, Integer startPrice, Integer endPrice, String color) {
        PageHelper.startPage(pageNO,PAGE_SIZE);
        PageInfo<CarBean> info = PageInfo.of(carMapper.findByItem(startPrice,endPrice,color));
        return info;
    }

    @Override
    public void add(CarBean car) {
        carMapper.add(car);
    }

    @Override
    public void del(int id) {
        carMapper.del(id);
    }

    @Override
    public void update(int id, int price) {
        carMapper.update(id,price);
    }

    @Override
    public CarBean findById(int id) {
        return carMapper.findById(id);
    }
}
